home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 May / maximum-cd-1999-05.iso / Canvas 6 / DATA1.CAB / English_Tutorial_Files / Viewpage / ColTxt.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-04  |  2.1 KB  |  77 lines

  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Rectangle;
  4. import java.io.DataInputStream;
  5. import java.io.IOException;
  6.  
  7. final class ColTxt extends ColObj {
  8.    private Color m_fillClr;
  9.    private int m_rectWidth;
  10.    private float m_rectX;
  11.    private float m_rectY;
  12.    private String m_txtStr;
  13.    private ColGrph m_colGraphicObj;
  14.    public Rectangle m_bounds;
  15.  
  16.    public void draw(Graphics var1) {
  17.       int var2 = this.m_colGraphicObj.m_fontMtrc.stringWidth(this.m_txtStr);
  18.       int var3 = (int)((float)this.m_rectWidth * this.m_colGraphicObj.m_mag);
  19.       int var4 = var3 - var2;
  20.       if (this.m_colGraphicObj.m_overrideColor != null) {
  21.          var1.setColor(this.m_colGraphicObj.m_overrideColor);
  22.       } else {
  23.          var1.setColor(this.m_fillClr);
  24.       }
  25.  
  26.       if ((var4 < 0 ? -var4 : var4) <= 4) {
  27.          var1.drawString(this.m_txtStr, (int)((this.m_rectX + 0.5F - this.m_colGraphicObj.m_xOrg) * this.m_colGraphicObj.m_mag), (int)((this.m_rectY + 0.5F - this.m_colGraphicObj.m_yOrg) * this.m_colGraphicObj.m_mag));
  28.       } else {
  29.          int var5 = (int)((this.m_rectY + 0.5F - this.m_colGraphicObj.m_yOrg) * this.m_colGraphicObj.m_mag);
  30.          float var6 = (this.m_rectX + 0.5F - this.m_colGraphicObj.m_xOrg) * this.m_colGraphicObj.m_mag;
  31.          float var8 = 0.0F;
  32.          new String();
  33.          int var9 = this.m_txtStr.length();
  34.          float var7 = (float)(var3 - var2) / (float)(var9 - 1);
  35.  
  36.          for(int var10 = 0; var10 < var9; ++var10) {
  37.             String var11 = this.m_txtStr.substring(var10, var10 + 1);
  38.             var1.drawString(var11, (int)(var6 + var8), var5);
  39.             var8 += (float)this.m_colGraphicObj.m_fontMtrc.stringWidth(var11) + var7;
  40.          }
  41.  
  42.       }
  43.    }
  44.  
  45.    public int getType() {
  46.       return 5;
  47.    }
  48.  
  49.    public Rectangle getBounds() {
  50.       return this.m_bounds;
  51.    }
  52.  
  53.    public ColTxt(DataInputStream var1, int var2, ColGrph var3, Graphics var4) throws IOException {
  54.       this.m_fillClr = Color.black;
  55.       this.m_txtStr = new String();
  56.       this.m_bounds = new Rectangle();
  57.       this.m_colGraphicObj = var3;
  58.       if ((var2 & 1) != 0) {
  59.          this.m_fillClr = new Color(var1.readInt());
  60.       }
  61.  
  62.       this.m_rectX = (float)var1.readShort() + (float)var1.readShort() / 65536.0F;
  63.       this.m_rectY = (float)var1.readShort() + (float)var1.readShort() / 65536.0F;
  64.       this.m_rectWidth = var1.readShort();
  65.  
  66.       for(int var5 = var1.readShort(); var5 > 0; --var5) {
  67.          String var10001 = this.m_txtStr;
  68.          this.m_txtStr = var10001 + (char)var1.readShort();
  69.       }
  70.  
  71.       this.m_bounds.x = (int)this.m_rectX;
  72.       this.m_bounds.width = this.m_colGraphicObj.m_fontMtrc.stringWidth(this.m_txtStr);
  73.       this.m_bounds.height = this.m_colGraphicObj.m_fontMtrc.getLeading() + this.m_colGraphicObj.m_fontMtrc.getMaxAscent() + this.m_colGraphicObj.m_fontMtrc.getMaxDescent();
  74.       this.m_bounds.y = (int)this.m_rectY - this.m_bounds.height;
  75.    }
  76. }
  77.